<!--
/***********************************************
* 파일명 : emp_mgr.jsp
* 기  능 : 사원관리 메인 화면
* 최초 작성일 : 2008/02/04
* @author : Yang Chang Hwan
*************************************************/ 
-->
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib 	prefix="s" 		uri="/struts-tags"%>
<%response.addHeader("X-UA-Compatible" , "IE=EmulateIE7"); %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<s:head theme="ajax"  />
	<script src="/inc/js/aa.js"></script>
	<meta http-equiv="Content-Type" 	content="text/html; charset=UTF-8" />
	<meta http-equiv="pragma" 			content="no-cache" />
	<meta http-equiv="cache-control" 	content="no-cache" />
	<meta http-equiv="expires" 			content="0" />
	<title>사원관리</title>
	<!-- ============================== J A V A S C R I P T		S T  A R T ============================== -->
	<script type="text/javascript">


    	var emp_no = 0;

    	function doOnLoad()
    	{
    		// 달력
    		cal1 = new dhtmlxCalendarObject('standard_date', false, {isYearEditable: true});
    		cal1.setYearsRange(2000, 2050);
    		cal1.setPosition(20,-82);
    		cal1.draw();
    		cal1.setOnClickHandler(selectDate1);

    		cal2 = new dhtmlxCalendarObject('standard_date', false, {isYearEditable: true});
    		cal2.setYearsRange(2000, 2050);
    		cal2.setPosition(20,-82);
    		cal2.draw();
    		// cal2.setOnClickHandler(selectDate2);

    		document.getElementById('standard_date').onfocus = function() { if (cal2.isVisible()) cal2.hide(); }

    		document.body.onclick = function(){calendarHide("cal1,cal2","D");};
    	}


		//성명조회시 키를 눌렀을 때	//disabled=""
		function fnc_searchName(dis) {
			
			if (event.keyCode == 13) {
				
				if (dis.value.length < 1) {
					alert("조회하실 사원명을 입력하시기 바랍니다.") ;
					return false;
				} else {
					frm_search();
					//return getList('search');
					return false;
				}
			}
			
			//if (dis.value.length > 0 ) {
			//	$("#semp_no").attr("disabled" , "disabled");
			//} else {
			//	$("#semp_no").removeAttr('disabled');
			//}

			return false;
			
		}

		function frm_search() {
			getList('search');
			return false;
		}
        	
	
		/*************************************************************************************************/
	    /**
	    *그룹선택이 변경될 경우에 팀과 사원  list를 변경한다.
	    */
	    function selectChange(type) {
	    
	    	if (type == "group") {
	    		$("#sgroup").css({backgroundColor:'#3366FF', color:'#FFFFFF'});
	    		if($("#sgroup").val()=="ALL"){
	    			$("#sgroup").css({backgroundColor:'#ffffff',color:'#656464'});
		    		}
				dojo.event.topic.publish("show_team");	//팀
				
				dojo.event.topic.publish("show_emp");	//사원
	    	} else if (type == "team") {
	    		$("#steam").css({backgroundColor:'#3366FF', color:'#FFFFFF'});
	    		if($("#steam").val()=="ALL"){
	    			$("#steam").css({backgroundColor:'#ffffff', color:'#656464'});
		    		}
	    			dojo.event.topic.publish("show_emp");	//사원
	    	}
	    	  else if (type == "emp")  {
	    		$("#semp_no").css({backgroundColor:'#3366FF',color:'#FFFFFF'});
	    		if($("#semp_no").val() == "ALL"){
                    $("#semp_no").css({backgroundColor:'#ffffff',color:'#656464'});
		    		}
					//dojo.event.topic.publish("show_emp");	//사원
                          
		    }
    

		return false;
		}

        function fnc_select(){

			$("#retired").css({backgroundColor:'#3366FF',color:'#FFFFFF'});
    		if($("#retired").val() == "ALL"){
                $("#retired").css({backgroundColor:'#ffffff',color:'#656464'});
	    		}
    		return false;
		}

		function fnc_selectVa(){

			$("#long_vaca").css({backgroundColor:'#3366FF',color:'#FFFFFF'});
    		if($("#long_vaca").val() == "ALL"){
                $("#long_vaca").css({backgroundColor:'#ffffff',color:'#656464'});
	    		}
    		return false;
		}

		
		/*************************************************************************************************/
		
		/**
		*	부서선택시 사원list 조회 - ajax
		*/
		function fnc_selectChange(f) {
			
			dojo.event.topic.publish("show_team");
			dojo.event.topic.publish("show_emp");
			return false;
		}
		
		//조회버튼
		function fnc_retrieve() {
			call_dojo();
			return false;
		} 
		
		//ajax로 조회리스트 호출.
	    function call_dojo() {
	        dojo.event.topic.publish("ajax_list");
	    }
	    
	    //사원등록
	    function fnc_reg_emp(f) {
	    	var w = 325;
	       	var h = 440;
	       
	       	var x = fnc_center_x(w);
	       	var y = fnc_center_y(h);
	       	
	    	var uri 	= 	"openRegEmp_p.action";
	    	var nm		=	"p_emp";
	    	var attr    =   "width=" + w + " , height=" + h + " , top=" + y + " , left=" + x + " , status=no";       //window size
	    	
	    	window.open(uri , nm , attr);
	    	
	    	return false;
	    }
	    
	    //변경
	    function fnc_mod_emp(emp_no , mode) {

	    	var w = 800;
	        var h = 480;
	       	//var w = 350;
	       	//var h = 425;
	       
	       	var x = fnc_center_x(w);
	       	var y = fnc_center_y(h);
	    
	    	var f		=	document.frm;
	    	
	    	var uri 	= 	"openModEmp_p.action";
	    	var nm		=	"p_emp";
	    	var attr    =   "width=" + w + " , height=" + h + " , top=" + y + " , left=" + x + " , status=no";       //window size
	    	
	    	if (emp_no.replace(/^\s\s*/, '').replace(/\s\s*$/, '').length != 0) {
		    	uri			+=	"?" + "emp_no=" + emp_no;
	    	}
	    		
	    	window.open("" , nm , attr);
	    	
	    	f.target 	= 	nm;
	    	f.action	=	uri;
	    	
	    	f.submit();
	    	
	    	return false;
	    }
	    
	    //권한 부여
	    function fnc_auth(f) {
	    	
	    	var flag = false;

	    	
			if (typeof f.s_chk == undefined) {
				alert("<s:text name="alert.message.retrieveNoData" />\r\n<s:text name="alert.message.SystemError" />");
				return false;
			}
			
			if (!f.s_chk.length) {
				//1개존재할 경우
				if (!f.s_chk.checked) {
					alert("<s:text name="alert.message.selectData" />");
					f.s_chk.focus();
				} else {
					emp_no	=	f.s_chk.value
					fnc_auth_dept();
				}
				
				return false;
			} else {
				//여러개 일 경우
				for (var i = 0 ; i < f.s_chk.length ; i++) {
					if (f.s_chk[i].checked) {
						emp_no	=	f.s_chk[i].value
						flag = true;
						break;
					}
				}
				
				if (!flag) {
					alert("<s:text name="alert.message.selectData" />");
					if (typeof f.s_chk.length == undefined) {
						f.s_chk.focus();
					} else {
						f.s_chk[0].focus();
					}
					
				} else {
					fnc_auth_dept();
				}
				
			}
	    	
	    	return false;
	    }
	    
	    //권한부여 팝업실행
	    function fnc_auth_dept() {

	    	var w = 570;
	       	var h = 250;
	       
	       	var x = fnc_center_x(w);
	       	var y = fnc_center_y(h);
	       	
	    	var uri 	= 	"openEmpDeptAuth_p.action";
	    	var nm		=	"p_emp";
	    	var attr    =   "width=" + w + " , height=" + h + " , top=" + y + " , left=" + x + " , status=no";       //window size
	    	
	    	uri 		+= 	"?emp_no=" + emp_no;
	    	
	    	window.open(uri , nm , attr);
	    	
	    }

	    //휴직버튼 클릭시
	    function fnc_longvacation(f) {
	    	
	    	var flag = false;

	    	
			if (typeof f.s_chk == undefined) {
				alert("<s:text name="alert.message.retrieveNoData" />\r\n<s:text name="alert.message.SystemError" />");
				return false;
			}
			
			if (!f.s_chk.length) {
				//1개존재할 경우
				if (!f.s_chk.checked) {
					alert("<s:text name="alert.message.selectData" />");
					f.s_chk.focus();
				} else {
					emp_no	=	f.s_chk.value
					fnc_longvacation_dept();
				}
				
				return false;
			} else {
				//여러개 일 경우
				for (var i = 0 ; i < f.s_chk.length ; i++) {
					if (f.s_chk[i].checked) {
						emp_no	=	f.s_chk[i].value
						flag = true;
						break;
					}
				}
				
				if (!flag) {
					alert("<s:text name="alert.message.selectData" />");
					if (typeof f.s_chk.length == undefined) {
						f.s_chk.focus();
					} else {
						f.s_chk[0].focus();
					}
					
				} else {
					fnc_longvacation_dept();
				}
				
			}
	    	
	    	return false;
	    }

	    //휴직관련 팝업실행
	    function fnc_longvacation_dept() {

	    	var w = 800;
	       	var h = 300;
	       
	       	var x = fnc_center_x(w);
	       	var y = fnc_center_y(h);
	       	
	    	var uri 	= 	"openEmpDeptLongvacation_p.action";
	    	var nm		=	"p_emp";
	    	var attr    =   "width=" + w + " , height=" + h + " , top=" + y + " , left=" + x + " , status=no";       //window size
	    	
	    	uri 		+= 	"?emp_no=" + emp_no;
	    	
	    	window.open(uri , nm , attr);
	    	
	    }


	    //popup 정가운데 띄우기
		function fnc_center_x(w) {

	       	var x;
	       	
			x =  (screen.availWidth - w) / 2;

	       	return x;
		}

	  	//popup 정가운데 띄우기
		function fnc_center_y(h) {

	       	var y;
	       	
			y =  (screen.availHeight - h) / 2;

	       	return y;
		}

	  	//엑셀 다운로드
	  	function fnc_empExcel() {

			var f = document.frm;
			
			f.action = "empExcel.action";		//att_struts.xml
			f.submit();
		  	
		  	return false;
	  	}

	</script>
</head>
<!--body onload="call_dojo()"-->
<body onload="doOnLoad();">
	<div class="fl_ri">
		<div id="contants_box">
			<div id="tit">
				<span class="fl_ri tit_navi">Home &gt; 관리자 &gt; <span class="f_b">사원관리</span><img src="/images/btl_navi.gif" class="img_tp" /></span>
				<div class="fl_le"><img src="/images/tit_menu05_img03.gif" /></div>
			</div>
		<s:form name="frm" id="frm" theme="simple" onsubmit="return false;">
			<div id="search01">
			<s:hidden id="cur_page" 	name="cur_page"/>
			<s:hidden id="crud_type" 	name="crud_type"/>
				<!-- -------------------------------------	C O N D I T I O N 	S T A R T------------------------------------- -->
				<div id="search_box02">
					<ul>
						<li class="txt">그룹</li>
						<li class="input">
							<s:select name="sgroup" id="sgroup" list="listGroup" 	headerKey="ALL" headerValue="::전체::" listKey="upper_dept_no" listValue="dept_nm" cssClass="combobox120se" onchange="return selectChange('group')" />
						</li>
						<li class="txt01">팀</li>
						<li class="input">
							<s:url id="team_url" action="com_select_team_s" />
							<s:div showLoadingText="false" id="team_div" href="%{team_url}" theme="ajax" listenTopics="show_team" formId="frm"/>
						</li>
						<li class="txt01">사원</li>
						<li class="input">
							<s:url id="emp_url" action="com_select_emp_s" />
							<s:div showLoadingText="false" id="emp_div" href="%{emp_url}" theme="ajax" listenTopics="show_emp" formId="frm"/>
						</li>
						<li class="txt01">성명 조회</li>
						<li class="input">
							<!--input type="text" name="empNm" id="empNm" class="input_75se" maxlength="5" /-->
							<input type="text" name="empNm" id="empNm" class="input_75se" maxlength="5" onkeyup="return fnc_searchName(this)"/>
						</li>
					</ul>
					<ul>
						<li class="txt">재직여부</li>
						<li class="input">
							<s:select name="retired" id="retired" list="#{'Y':'Y' , 'N':'N'}" 	headerKey="ALL" headerValue="::전체::" cssClass="combobox120se" onchange="return fnc_select()"/>
						</li>
						<li class="txt01">휴직여부</li>
						<li class="input">
							<s:select name="long_vaca" id="long_vaca" list="#{'Y':'Y' , 'N':'N'}" 	headerKey="ALL" headerValue="::전체::" cssClass="combobox100se" onchange="return fnc_selectVa()"/>
						</li>
					</ul>
					<ul class="btn">
						<li>
							<!-- -------------------------------------	B U T T O N 	S T A R T------------------------------------- -->
							<span class="fl_ri">
								<!--s:submit type='image' src="/images/btn_search03.gif" 	cssClass="img_tm" title="확인" 		value="확인" 	onclick="return fnc_retrieve()" /-->
								<!--s:submit type='image' src="/images/btn_search03.gif" cssClass="img_tm" title="조회"  onclick="return getList('search')" /-->	
								<s:submit type='image' src="/images/btn_search.gif" cssClass="img_tm" title="조회"  onclick="return frm_search()" />
								<s:submit type='image' src="/images/btn_add.gif" 		cssClass="img_tm" title="권한부여" 	value="권한부여" onclick="return fnc_auth(this.form)" />
								<s:submit type='image' src="/images/btn_add_bt.gif" 		cssClass="img_tm" title="휴직등록" 	value="휴직등록" onclick="return fnc_longvacation(this.form)" />
								<s:submit type='image' src="/images/btn_sub.gif" 		cssClass="img_tm" title="사원등록" 	value="사원등록" onclick="return fnc_reg_emp(this.form)" />
								<s:submit type='image' src="/images/btn_excel.gif" 		cssClass="img_tm" title="엑셀다운로드" 	value="엑셀다운로드" onclick="return fnc_empExcel(this.form)" />
							</span>
							<!-- -------------------------------------	B U T T O N 	E	N	D------------------------------------- -->
						</li>
					</ul>
					<!-- -------------------------------------	C O N D I T I O N 	E	N	D------------------------------------- -->
				</div>
			</div>				
		<!-- ajax로 데이터를 조회해 온다. -->
		<center>
		<s:url id="ajax_list"  action="emp_manager_list_ajax" />
		<s:div id="itemAmtlistDiv" theme="ajax" executeScripts="true" showLoadingText="true" loadingText='<img src="./images/loading_request.gif" />' href="%{ajax_list}" listenTopics="ajax_list" formId="frm" />
		</center>
		</s:form>
		</div>
	</div>
</body>
</html>